import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:nyh_motorcade_app/widgets/custom_app_bar.dart';
import 'package:nyh_motorcade_app/widgets/custom_text_field.dart';
import 'add_account_controller.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AddAccountPage extends StatelessWidget {
  final controller = Get.put(AddAccountController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colours.color_background,
      appBar: CustomAppBar(
        context: context,
        title: "添加账户",
        actions: [
          GetBuilder<AddAccountController>(
            builder: (controller) {
              return TextButton(
                onPressed: () {
                  controller.confirm();
                },
                child: Text(
                  "确定",
                  style: TextStyle(
                    color: (controller.accountName.isNotEmpty && controller.accountCode.isNotEmpty) ? Colours.color_theme : Colours.color_cfcfd5,
                    fontSize: 14.sp,
                  ),
                ),
              );
            },
          ),
        ],
      ),
      body: Column(
        children: [
          SizedBox(
            height: 12.w,
          ),
          GetBuilder<AddAccountController>(
            builder: (controller) {
              return CustomTextField(
                "请输入资金账号",
                focusNode: controller.codeFocus,
                textStyle: TextStyle(color: Colours.color_text_theme, fontSize: 14.sp),
                hintStyle: TextStyle(color: Colours.color_cfcfd5, fontSize: 14.sp),
                fillColor: Colours.color_white,
                contentPadding: EdgeInsets.symmetric(vertical: 17.w, horizontal: 16.w),
                suffixIconPadding: EdgeInsets.only(right: 16.w),
                buildClearSuffixIcon: true,
                onChanged: (value) {
                  controller.setAccountCode(value);
                },
              );
            },
          ),
          SizedBox(
            height: 12.w,
          ),
          GetBuilder<AddAccountController>(
            builder: (controller) {
              return CustomTextField(
                "请输入账户名称",
                focusNode: controller.nameFocus,
                textStyle: TextStyle(color: Colours.color_text_theme, fontSize: 14.sp),
                hintStyle: TextStyle(color: Colours.color_cfcfd5, fontSize: 14.sp),
                fillColor: Colours.color_white,
                contentPadding: EdgeInsets.symmetric(vertical: 17.w, horizontal: 16.w),
                suffixIconPadding: EdgeInsets.only(right: 16.w),
                buildClearSuffixIcon: true,
                onChanged: (value) {
                  controller.setAccountName(value);
                },
              );
            },
          ),
        ],
      ),
    );
  }
}
